﻿using System;
using System.Windows;
using Csla.Xaml;
using HeThongThongTin.Library;

namespace HeThongThongTin.UI.SL.TiepNhanHoSo.TNHS_HoSoTiepNhan
{
    public partial class TNHS_HoSoTiepNhan_ListViewModel : ViewModel<TNHS_HoSoTiepNhanList>
    {

        public TNHS_HoSoTiepNhan_ListViewModel(string mode)
        {
            BeginRefresh("GetTNHS_HoSoTiepNhanList", mode);

        }
        
        public void GetTNHS_HoSoTiepNhan_ListViewModel(string mode)
        {
            BeginRefresh("GetTNHS_HoSoTiepNhanList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(TNHS_HoSoTiepNhanInfo), typeof(TNHS_HoSoTiepNhan_ListViewModel), null);
        public TNHS_HoSoTiepNhanInfo SelectedItem
        {
            get { return (TNHS_HoSoTiepNhanInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteTNHS_HoSoTiepNhan(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                HeThongThongTin.Library.TNHS_HoSoTiepNhan.DeleteTNHS_HoSoTiepNhan(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetTNHS_HoSoTiepNhanList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
